package com.pictures;


import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends Activity {

	private Button btn;
	private ImageView img;
	static final int FOTO_MODE = 0;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
		btn = (Button)findViewById(R.id.button1);
		img = (ImageView)findViewById(R.id.imageView1);
		
		btn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
			
				Intent i = new Intent(MainActivity.this, CamaraView.class);
				startActivityForResult(i, FOTO_MODE);
				
			}
		});
		
		
		
	}
	
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {   
    	switch(requestCode) { 
	    	case FOTO_MODE:   
	        	if (resultCode == 0)
	        	{
	        		Bundle params = data.getExtras();
	        		String s = params.getString("FOTO_SRC");
	        		Bitmap b = BitmapFactory.decodeFile(s);
	        		img.setImageBitmap(b);
	     /*   		
	        		if (params.getChar("FOTO_POSICION") == 'V'){
	        			img.getLayoutParams().height = 100;
	        			img.getLayoutParams().width = 30;
	        		}else{
	        			img.getLayoutParams().height = 30;
	        			img.getLayoutParams().width = 100;
	        			
	        		}
	        		 
	     */   		
	        	}
	        		
	    		break;
	    		
    	}
    	
        
    }	
	

}
